package com.pearl.jacksoncore.demo.databind.anno;

import com.fasterxml.jackson.annotation.*;

/**
 * @author TD
 * @version 1.0
 * @date 2024/3/21
 */

@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserInject {


    public UserInject() {
        System.out.println("无参构造");
    }


    @JsonCreator
    public UserInject(@JsonProperty("name") String name, @JsonProperty(value = "phone") String phone)  {
        this.name = name;
        this.phone = phone;
        System.out.println("有参构造");
    }

/*
    public static UserInject createUser(@JsonProperty("name") String name, @JsonProperty(value = "phone") String phone) {
        System.out.println("createUser");
        return new UserInject(name, phone);
    }
*/

    // 姓名
    private String name;

    //@JacksonInject(value = "phone", useInput = OptBoolean.FALSE)
    private String phone;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        System.out.println("setName");
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        System.out.println("setPhone");
        this.phone = phone;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", phone='" + phone + '\'' +
                '}';
    }
}
